package com.bidevalution.business.impl;

import com.bidevalution.business.common.BaseService;
import com.bidevalution.business.service.BeSectionLayoutService;
import com.bidevalution.business.service.JdbcTemplateService;
import com.bidevalution.dao.entity.BeSectionLayout;
import com.bidevalution.dao.entity.BeSectionLayoutKey;
import com.bidevalution.dao.mapper.BeSectionLayoutMapper;
import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
import com.qtp.core.util.OConvertUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by glodon on 2019-08-20.
 */
@Service
public class BeSectionLayoutServiceImpl extends BaseService implements BeSectionLayoutService {
    @Autowired
    private BeSectionLayoutMapper beSectionLayoutMapper;
    @Autowired
    private JdbcTemplateService jdbcTemplateService;
    @Override
    public BeSectionLayout getBeSectionLayout(String sectionStepId, String layoutCode) throws Exception {
        BeSectionLayoutKey beSectionLayoutKey = new BeSectionLayoutKey();
        beSectionLayoutKey.setSectionStepId(sectionStepId);
        beSectionLayoutKey.setLayoutCode(layoutCode);
        return beSectionLayoutMapper.selectByPrimaryKey(beSectionLayoutKey);
    }

    @Override
    public List<Map<String, Object>> getDataList(String sqlQuery,Map<String, Object> paramMap) throws Exception {
    	logger.info(sqlQuery+":"+paramMap);
    	
    	if(StringUtils.isEmpty(sqlQuery)) {
    		return new ArrayList<Map<String, Object>>();
    	}
    	return jdbcTemplateService.selectForList(sqlQuery, paramMap);
    }
}
